package com.ruoyi.web.studentmanagementsystem.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.web.studentmanagementsystem.dto.*;
import com.ruoyi.web.studentmanagementsystem.pojo.SysSubject;
import com.ruoyi.web.studentmanagementsystem.service.ISysSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: SubjectController
 * Package: com.ruoyi.web.studentmanagementsystem.controller
 * Description:
 *
 * @Author Mr. o
 * @Create 2023/11/11 21:50
 * @Version 1.0
 */
@RestController
@RequestMapping("/ISysSubjectService")
@Api(tags = "科目表接口相关")
public class SubjectController {
    @Resource
    @Autowired
    private ISysSubjectService iSysSubjectService;

    @PostMapping(  "/insertSubject")
    @ApiOperation("科目表——增")
    public R<String> insertSubject(@RequestBody ISysSubjectDTO subject) {
        iSysSubjectService.insertSubject(subject);
        return R.ok();
    }

    @PostMapping(  "/deleteSubject/{studentId}")
    @ApiOperation("科目表——删")
    public R<String> deleteSubject(@PathVariable String studentId) {
        iSysSubjectService.deleteSubject(studentId);
        return R.ok();
    }

    @PostMapping(  "/selectSubject/{studentId}")
    @ApiOperation("科目表——查")
    public R<List<SysSubject>> selectSubject(@PathVariable String studentId) {
        return R.ok(iSysSubjectService.selectSubject(studentId));
    }

    @PostMapping(  "/updateSubject")
    @ApiOperation("科目表——改")
    public R<String> updateSubject(@RequestBody IISysSubjectDTO subject) {
        iSysSubjectService.updateSubject(subject);
        return R.ok();
    }
}
